package com.controller;


import com.entity.OrderDetail;
import com.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 *  入库订单详情前端控制器
 */
@Controller
@RequestMapping("/orderDetail")
public class OrderDetailController {

    @Autowired
    private OrderDetailService orderDetailService;

    //获取订单详情
    @GetMapping("/getOrderDetail")
    @ResponseBody
    public List<OrderDetail> getOrderDetail(String orderNo){
        List<OrderDetail> list = this.orderDetailService.list(orderNo);
        return list;
    }

    //检查订单详情页面的批次号，此处若订单号相同，批次号可以重复
    @PostMapping("/checkBatchNoForEdit")
    @ResponseBody
    public String checkBatchNoForEdit(String orderNo,String batchNoStr){
        boolean checkBatchNo = this.orderDetailService.checkBatchNo(orderNo,batchNoStr);
        if(checkBatchNo) return "success";
        return "fail";
    }



}

